<template>
  <div class="friend-list">
    <div class="left">
      <img :src="listData.headimgurl"/>
      <div class="detail">
        <div class="name">{{listData.nickname}}</div>
        <div class="phone">{{phone}}</div>
      </div>
    </div>
    <div class="date">{{createdTime}}</div>
  </div>
</template>

<script>
import mixins from 'comp/mixins'

export default {
  mixins: [mixins],
  props: {
    listData: {
      type: Object,
      default: {},
    },
  },
  data () {
    return {
      icons: {
        imageMissBg: `${require('static/images/image-miss-bg.png')}`
      }
    }
  },
  computed: {
    imageMissBg () {
      return `background-image: url(${this.icons.imageMissBg});`
    },
    createdTime () {
      let output
      const time = this.listData.created
      if (time) {
        output = this.timeFilter(time)
      }
      return output
    },
    phone () {
      let output
      const phone = this.listData.phone
      if (phone) {
        output = phone.replace(/(\d{3})(\d{4})(\d{4})/, '$1****$3')
      }
      return output
    }
  }
}
</script>

<style lang="less" scoped>
.friend-list {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20rpx 30rpx;
  border-bottom: 1rpx solid #e6ebf0;
  background-color: #fff;
  .left {
    display: flex;
    align-items: center;
    flex: 1;
    img {
      display: block;
      width: 100rpx;
      height: 100rpx;
      border: 1rpx solid #e6ebf0;
      &.has-bg {
        background-size: 53rpx 41rpx;
        background-repeat: no-repeat;
        background-position: center center;
        background-color: #fff;
      }
    }
  }
  .detail {
    flex: 1;
    padding: 0 20rpx 0 30rpx;
    .name {
      font-size: 32rpx;
      color: #333;
    }
    .phone {
      display: flex;
      align-items: center;
      font-size: 26rpx;
      color: #777;
      margin-top: 10rpx;
      i {
        display: block;
        width: 28rpx;
        height: 28rpx;
        background-size: contain;
        margin-right: 10rpx;
      }
    }
  }
  .date {
    font-size: 26rpx;
    color: #888;
  }
}
</style>
